/**
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates.
 * The Universal Permissive License (UPL), Version 1.0
 */
"use strict";
define(["ojs/ojcore","jquery","ojs/ojeditablevalue","ojs/ojradiocheckbox"],function(a,g){(function(){a.Ra("oj.ojRadioset",g.oj.editableValue,{version:"1.0.0",defaultElement:"\x3cdiv\x3e",widgetEventPrefix:"oj",options:{disabled:!1,value:void 0},refresh:function(){this._super();this.ab()},widget:function(){return this.ZLa},Yf:function(b,d){var e;this._super(b,d);a.Fe.Cp([{ha:"disabled",Sd:!0},{ha:"placeholder"},{ha:"required",wh:!0,Sd:!0},{ha:"title"}],d,this);this.Gi=this.XS();void 0===d.value&&(e=
this.Gi.filter(":checked"),e=0===e.length?void 0:e.val(),void 0!==e&&this.option("value",e,{_context:{Cd:!0,kb:!0}}),void 0===this.options.value&&(this.options.value=null))},_ComponentCreate:function(){var a=this.element;this._super();if(a.is("fieldset"))throw Error("ojRadioset cannot be bound to a fieldset. Use a div instead.");this.Gi._ojRadioCheckbox().attr("data-oj-internal",!0);this.ZLa=a.addClass("oj-radioset oj-component").attr("role","radiogroup").wrapInner("\x3cdiv class\x3d'oj-radioset-wrapper'\x3e\x3c/div\x3e");
this._on(this.xq)},Nh:function(){this._super();this.ab()},CQ:function(){this.Gi=this.XS();this.Gi.filter(".oj-radio").each(function(){var a=void 0!==g(this).attr("disabled")?!!g(this).prop("disabled"):!1;g(this)._ojRadioCheckbox("option","disabled",a)});this.Gi.not(".oj-radio")._ojRadioCheckbox()},Focus:function(){this.Xf().first().focus();return!0},FQ:function(){},XS:function(){var b=this.element,d=b.find("input[type\x3dradio]:first");0===d.length&&a.t.warn("Could not find any input type\x3dradio within this element");
d=d.attr("name");return void 0===d?(b=b.find("input[type\x3dradio]"),b.not("[name]")):b.find("input[type\x3dradio][name\x3d"+d+"]")},ph:function(a,b,e){a=this.element.find("input[type\x3dradio]");var f=a.filter(":checked");a=f.length?f:a.filter(":enabled").first();this.qh(b,e,{launcher:a})},_GetMessagingLauncherElement:function(){return this.widget()},ab:function(){this.et(this.options.disabled)},xq:{change:function(a){this.pH(a)}},pH:function(a){var d=this.Si();this.wc(d,a,b)},Si:function(){return this.Zx()},
Hl:function(a){var b=this.Gi.length,e,f,h;for(f=0;f<b;f++){h=g(this.Gi[f]);e=h[0].value;var k=h._ojRadioCheckbox("option","checked");a===e?k||h._ojRadioCheckbox("option","checked",!0):k&&h._ojRadioCheckbox("option","checked",!1)}},Zx:function(){var a=this.Gi.filter(":checked");return 0===a.length?null:a.val()},_GetDefaultStyleClass:function(){return"oj-radioset"},Xf:function(){if(null!=this.Gi)return this.Gi;this.XS()},zQ:function(){},PB:function(){return!0},et:function(a){a=!!a;this.Gi.each(function(){g(this).data("oj-_ojRadioCheckbox").lC(a)});
this.Gi._ojRadioCheckbox("refreshDisabled")},_setOption:function(a,b){this._superApply(arguments);"disabled"===a&&this.et(b)},getNodeBySubId:function(a){var b=this._super(a);b||(a=a.subId,"oj-radioset-inputs"===a&&(b=this.Gi.get()));return b||null},_destroy:function(){var a=this._super(),b=this.element[0].firstChild;this.Gi&&this.Gi._ojRadioCheckbox("destroy");g(b).contents().unwrap();return a}});var b={Fw:!1}})();a.Components.Xa("ojRadioset","editableValue",{properties:{disabled:{type:"boolean"},
value:{type:"string",writeback:!0}},methods:{destroy:{},refresh:{},widget:{}},extension:{_widgetName:"ojRadioset"}});a.Components.register("oj-radioset",a.Components.getMetadata("ojRadioset"))});